package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkResBean;

public class RecommendAdapter extends StkProviderMultiAdapter<StkResBean> {

    public RecommendAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new RecommendProvider());
    }

    private class RecommendProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_recommend;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            baseViewHolder.setText(R.id.tvRecommendItemName, bean.getName());
            baseViewHolder.setText(R.id.tvRecommendItemDesc,bean.getDesc());
            Date date=TimeUtils.string2Date(bean.getCreateAt(),new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
            baseViewHolder.setText(R.id.tvRecommendItemDate, TimeUtils.date2String(date,new SimpleDateFormat("yyyy-MM-dd")));
            Random random = new Random();
            int num = random.nextInt(8000) + 1000;
            baseViewHolder.setText(R.id.tvRecommendItemRead, num + "");
            if (baseViewHolder.getBindingAdapterPosition()==0){
                baseViewHolder.setImageResource(R.id.ivRecommendItemLog,R.drawable.azhiding);
            }else {
                baseViewHolder.setImageResource(R.id.ivRecommendItemLog,R.drawable.aretui);
            }
        }
    }

}
